use 	"./output/cities_expandedpatents", clear

** npi X month-of-year FEs **
egen	idxm = group(gen_id f_m)

** census region X year FEs **
egen	regyr = group(f_yr region)

*=======================*
*= Treatment variables  *
*=======================*

tab 	days_npis if f_myr==tm(1918m9)
gen		daysnpis = days_npis
*gen		longnpis = (days_npis>=90) & !mi(days_npis) // Natural break in data, about 61% have short

*=======================*
*= Main code  *
*=======================*

est clear

levelsof daysnpi, local(daylevels)
di `daylevels'
	
foreach l of local daylevels {
	gen		longnpis 			  = (daysnpis>=`l') & !mi(daysnpis) 
	gen 	post_X_longnpis_gt`l' = longnpis*(f_myr>=tm(1918m9))
	tab 	post_X_longnpis_gt`l'
	
	la var  post_X_longnpis_gt`l' "`l'"
	eststo est_`l': ppmlhdfe pat_wtd_inv post_X_longnpis_gt`l' if tin(1916m1, 1920m12), exp(pop_int) a(f_myr idxm regyr) cluster(gen_id)
	
	drop 	longnpis 
}

est drop est_28 est_29 est_33 est_39 est_156 est_162 est_164 est_168 est_170

set scheme plotplainblind
coefplot est_*, mcolor(sky) msymbol(O) drop(_cons) vertical  yline(0, lcolor(black)) ///
	legend(off) ciopts(recast(rcap) color(sky)) xlab(, angle(90)) ///
	xtitle("X = Days of NPIs") ytitle("Coef. on 1[Days of NPIS> X ]")

graph export	"$RES/FigureAX_longnpi_cutoffs.png", replace

browse city daysnpis if f_myr==tm(1918m8)
sort daysnpis

*drop if npi_id==6 //Chicago
*drop if npi_id==24 //NYC
*drop if npi_id==36 //SF

** WHO GETS DROPPED **
** gteq68 drops San Francisco
** gteq73 drops Chicago
** gteq78 drops New York City ** FIRST SIGNIFICANT EFFECTS
** gteq82 drops New Orleans
** gteq99 drops Indianapolis
/*
city	daysnpis
San Francisco, CA	67
Chicago, IL	68
New York City, NY	73
New Orleans, LA	78
Indianapolis, IN	82
Cleveland, OH	99
Toledo, OH	102
Minneapolis, MN	116
Cincinnati, OH	123
Oakland, CA	127
Milwaukee, WI	132
Omaha, NE	140
St Louis, MO	143
Louisville, KY	145
Columbus, OH	147
Denver, CO	151
Los Angeles, CA	154
Dayton, OH	156
Portland, OR	162
Spokane, WA	164
Seattle, WA	168
Kansas City, MO	170
*/
